/** 静态路由配置 */
import Home from '@/views/home'
import Cart from '@/views/cart'
import Category from '@/views/category'
import SubCategory from '@/views/category/SubCategory'
import Confirm from '@/views/confirm'
import Detail from '@/views/detail'
import Login from '@/views/login'
import Mine from '@/views/mine'
import NavBar from '@/components/nav-bar'
import TabBar from '@/components/tab-bar'
import SearchBar from '@/components/search-bar'

const routes = [
  {
    path: '/',
    redirect: '/home', // 重定向
    meta: {},
  },
  {
    path: '/home',
    name: '/home',
    components: {
      header: SearchBar,
      default: Home,
      footer: TabBar,

    },
    meta: {
      icon: '&#xe639;',
      title: '首页',
      inTabBar: true, // 在 tabbar 中
      noBack: true, // 不可返回（无返回按钮）
      replace: true, // 路由导航（replace()）
    },
  },
  {
    path: '/category',
    components: {
      header: NavBar,
      default: Category,
      footer: TabBar,
    },
    children: [
      {
        path: 'sub/:id',
        component: SubCategory,
        meta: {
          title: '分类',
        },
      },
    ],
    meta: {
      icon: '&#xe71b;',
      title: '分类',
      inTabBar: true,
      noBack: true,
      replace: true,
    },
  },
  {
    path: '/cart',
    components: {
      header: NavBar,
      default: Cart,
    },
    meta: {
      icon: '&#xe73d;',
      title: '购物车',
      inTabBar: true,
    },
  },
  {
    path: '/confirm',
    components: {
      header: NavBar,
      default: Confirm,
    },
    meta: {
      title: '确认订单',
    },
  },
  {
    path: '/detail',
    components: {
      header: NavBar,
      default: Detail,
    },
    meta: {
      title: '商品详情',
    },
  },
  {
    path: '/login',
    components: {
      header: NavBar,
      default: Login,
    },
    meta: {
      title: '用户登录',
    },
  },
  {
    path: '/mine',
    components: {
      header: NavBar,
      default: Mine,
      footer: TabBar,
    },
    meta: {
      icon: '&#xe61c;',
      title: '个人中心',
      inTabBar: true,
      noBack: true,
      replace: true,
    },
  },
]
export default routes
